using System.Collections.Generic;
using UnityEngine;

public class P_InteractCollision : MonoBehaviour
{
	private bool SuccessfulInteraction;

	private List<Component> ListOfInteractables = new List<Component>();

	private void OnTriggerEnter2D(Collider2D other)
	{
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<INT_Chat>()))
		{
			ListOfInteractables.Add((Component)(object)((Component)other).GetComponent<INT_Chat>());
		}
		if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<INT_Generic>()))
		{
			ListOfInteractables.Add((Component)(object)((Component)other).GetComponent<INT_Generic>());
		}
		if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<INT_ChangeBool>()))
		{
			ListOfInteractables.Add((Component)(object)((Component)other).GetComponent<INT_ChangeBool>());
		}
		if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<INT_ChangePlayerVariable>()))
		{
			ListOfInteractables.Add((Component)(object)((Component)other).GetComponent<INT_ChangePlayerVariable>());
		}
		if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<INT_DestroyComponent>()))
		{
			ListOfInteractables.Add((Component)(object)((Component)other).GetComponent<INT_DestroyComponent>());
		}
		if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<INT_PlaySound>()))
		{
			ListOfInteractables.Add((Component)(object)((Component)other).GetComponent<INT_PlaySound>());
		}
		if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<INT_EnableGameObject>()))
		{
			ListOfInteractables.Add((Component)(object)((Component)other).GetComponent<INT_EnableGameObject>());
		}
		if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<INT_SaveInt>()))
		{
			ListOfInteractables.Add((Component)(object)((Component)other).GetComponent<INT_SaveInt>());
		}
		Component val = null;
		float num = float.PositiveInfinity;
		foreach (Component listOfInteractable in ListOfInteractables)
		{
			if (Vector2.Distance(Vector2.op_Implicit(((Component)PlayerManager.Instance).transform.position), Vector2.op_Implicit(listOfInteractable.transform.position)) < num)
			{
				val = listOfInteractable;
			}
		}
		if ((Object)(object)val != (Object)null)
		{
			if (((object)val).GetType() == typeof(INT_Chat) && !SuccessfulInteraction)
			{
				((object)val).GetType().GetMethod("RUN").Invoke(val, null);
				SuccessfulInteraction = true;
			}
			if (((object)val).GetType() == typeof(INT_Generic) && !SuccessfulInteraction)
			{
				((object)val).GetType().GetMethod("Interact").Invoke(val, null);
				SuccessfulInteraction = true;
			}
			if (((object)val).GetType() == typeof(INT_ChangeBool) && !SuccessfulInteraction)
			{
				((object)val).GetType().GetMethod("RUN").Invoke(val, null);
				SuccessfulInteraction = true;
			}
			if (((object)val).GetType() == typeof(INT_ChangePlayerVariable) && !SuccessfulInteraction)
			{
				((object)val).GetType().GetMethod("RUN").Invoke(val, null);
				SuccessfulInteraction = true;
			}
			if (((object)val).GetType() == typeof(INT_DestroyComponent) && !SuccessfulInteraction)
			{
				((object)val).GetType().GetMethod("RUN").Invoke(val, null);
				SuccessfulInteraction = true;
			}
			if (((object)val).GetType() == typeof(INT_PlaySound) && !SuccessfulInteraction)
			{
				((object)val).GetType().GetMethod("RUN").Invoke(val, null);
				SuccessfulInteraction = true;
			}
			if (((object)val).GetType() == typeof(INT_EnableGameObject) && !SuccessfulInteraction)
			{
				((object)val).GetType().GetMethod("RUN").Invoke(val, null);
				SuccessfulInteraction = true;
			}
			if (((object)val).GetType() == typeof(INT_SaveInt) && !SuccessfulInteraction)
			{
				((object)val).GetType().GetMethod("RUN").Invoke(val, null);
				SuccessfulInteraction = true;
			}
		}
		ListOfInteractables.Clear();
		SuccessfulInteraction = false;
	}
}
